﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace ThouShaltNotBrick.Logic.GeneralObjects
{
    public sealed class BrickWithCurrentState
    {
        #region Properties
        #region Row
        /// <summary>
        /// Row property.
        /// </summary>
        public int Row
        {
            get { return mBrick.Row; }
        }
        #endregion

        #region Column
        /// <summary>
        /// Column property.
        /// </summary>
        public int Column
        {
            get { return mBrick.Column; }
        }
        #endregion

        #region BrickType
        /// <summary>
        /// BrickType property.
        /// </summary>
        public BrickType BrickType
        {
            get { return mBrick.BrickType; }
        }
        #endregion

        #region CurrentBrickStateIndex
        /// <summary>
        /// CurrentBrickStateIndex property.
        /// </summary>
        public int CurrentBrickStateIndex { get; private set; }
        #endregion

        private Brick mBrick;
        #endregion

        #region Constructors
        public BrickWithCurrentState(
            Brick pBrick)
        {
            mBrick = pBrick;
            CurrentBrickStateIndex = pBrick.InitialBrickStateIndex;
        }
        #endregion

        #region Methods
        public Texture2D GetCurrentBrickStateTexture()
        {
            BrickState currentBrickState = GetCurrentBrickState();
            if (currentBrickState != null)
            {
                return currentBrickState.Texture;
            }
            else
            {
                return null;
            }
        }

        public BrickState GetCurrentBrickState()
        {
            List<BrickState> brickStates = BrickType.GetAllBrickStates();
            if (0 <= CurrentBrickStateIndex && CurrentBrickStateIndex < brickStates.Count)
            {
                return brickStates[CurrentBrickStateIndex];
            }
            else
            {
                return null;
            }
        }

        public void SetNextBrickState()
        {
            CurrentBrickStateIndex++;
        }
        #endregion
    }
}